package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
	HuYiWuXian struct {
		APIID  string
		APIKEY string
	}
	QiNiuYun struct {
		AccessKey string
		SecretKey string
		Bucket    string
		URL       string
	}
}

var ConfigData AppConfig

func Init() {
	viper.SetConfigFile("../appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		panic(err)
	}
	fmt.Println("配置加载成功", ConfigData)
}
